import Vue from 'vue'
import Vuex from 'vuex'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import persist from 'vuex-persistedstate'
Vue.use(ElementUI);
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo:[
      {
        // "cardNumber":Math.floor(Math.random()*9+1)+""+Math.floor(Math.random()*1000000)+Math.floor(Math.random()*1000000)
        "cardId":51168119990723,//身份证号
        "userName":"张三",
        "userAge":28,
        "region":"身份证",//身份证类型
        "cardNumber2":["511684445678415","611684445678415","611684445678415"],//客户银行卡号
        "cardNumber":[
          {
          "id":"511684445678415",//客户银行卡号
          "money":1000,//客户余额
          "cardAction":"审核通过",//审核状态
        },
        { 
          "id":"611684445678415",
          "money":2000,
          "cardAction":"审核中",
        },
        {
          "id":"611684445678415",
          "money":3000,
          "cardAction":"审核失败",
        }
      ],
        "date1":"2021-11-05",
        "phone":18090516745,
        "resource":"男"
      }
    ]
  },
  getters: {
  },
  mutations: {
     addInfo(e,e1){//添加用户
      e.userInfo.push(e1)
        console.log(e.userInfo,"注册")
    },
    addInfo2(e,e1){//渲染列表点击添加后用户存款信息
      e.userInfo[e1.index].cardNumber.unshift(e1)
      console.log(e.userInfo[e1.index].cardNumber,45456456)
    },
    addInfo3(e,e1){//添加用户已知账号
      e.userInfo[e1.index1].cardNumber[e1.index2]=e1
    },
    delet(e,e1){//删除用户银行卡内容
      e.userInfo[e1.index1].cardNumber.splice(e1.index2,1)
    },
    addNumner(e,e1){//添加用户账号
      e.userInfo[e1[1]].cardNumber2.push(e1[0])
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [//vuex数据持久化处理
    new persist({
      storage: window.localStorage,
    }),
  ],
})
